package demo05_Prototype.model;

/**
 * 实现clone接口的方式 深拷贝
 */
public class CustomerDeepClone01 implements Cloneable{


    private String name;
    private Integer age;
    private double height;
    private AddressDeepClone01 address;

    public CustomerDeepClone01() {
    }

    public CustomerDeepClone01(String name, Integer age, double height, AddressDeepClone01 address) {
        this.name = name;
        this.age = age;
        this.height = height;
        this.address = address;
    }

    public AddressDeepClone01 getAddress() {
        return address;
    }

    public void setAddress(AddressDeepClone01 address) {
        this.address = address;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public double getHeight() {
        return height;
    }

    public void setHeight(double height) {
        this.height = height;
    }

    @Override
    public Object clone() throws CloneNotSupportedException {
        CustomerDeepClone01 clone = (CustomerDeepClone01) super.clone();
        clone.address = (AddressDeepClone01) clone.address.clone();
        return clone;
    }

    @Override
    public String toString() {
        return "CustomerDeepClone01{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", height=" + height +
                ", address=" + address +
                '}';
    }
}
